import { ServiceItem } from '../../svc/vms';
interface ListReq {
  name?: string;
  namespace?: string;
}

interface ListResp {
  total: number;
  items: Deploy[];
}

interface DeployItem {
  metadata: {
    name: string;
    namespace: string;
    creationTimestamp: string;
  };
  spec: {
    replicas: number;
    selector: {
      matchLabels: {
        app: string;
      };
    };
    template: {
      metadata: {
        creationTimestamp: string;
        labels: {
          app: string;
        };
      };
      spec: {
        containers: {
          name: string;
          image: string;
          ports: {
            name: string;
            containerPort: number;
            protocol: string;
          }[];
          resources: {};
          command: string[]
        }[];
        volumes: {}
      };
    };
    strategy: {};
  };
  status: {};
}
interface Deploy {
  deploy_name: string;
  namespace: string;
  create_time: string;
  deployment: DeployItem;
}

interface CreateReq {
  name: string;
  namespace: string;
  replicas: number;
  containers: {
    name: string;
    image: string;
    command: string[] | string;
    volumeMounts: {
      name: string
      mountPath: string
    }[]
    ports: {
      name: string;
      protocol: string;
      containerPort: number;
    }[];
  }[];
  volumes: {
    name: string
    configMap: {
      name: string
      items: {
        key: string
        path: string
      }[]
    }[]
  }[]
  is_create_svc: boolean;
  service: {
    type: string;
    ports: {
      name: string;
      port: number;
      targetPort: number;
      protocol: string;
    }[];
  };
}

interface UpdateReq {
  name: string;
  namespace: string;
  replicas: number;
  containers: {
    name: string;
    image: string;
    ports: {
      name: string;
      protocol: string;
      containerPort: number;
    }[];
  }[];
}

interface CreateResp {
  deployment: {
    info: DeployItem;
    is_ok: boolean;
    name: string;
  };
  is_create_svc: boolean
  service: {
    info: ServiceItem;
    is_ok: boolean;
    name: string;
  };
}


interface GetReq {
  name?: string;
  namespace?: string;
}

interface GetResp {
  deployment: DeployItem
}
interface DeleteReq {
  name?: string;
  namespace?: string;
}

interface UpdateResp {
  deployment: {
    info: DeployItem;
    is_ok: boolean;
    name: string;
  };
}

interface ListPodReq {
  namespace: string;
  deploy_name: string
}

interface Pod {
  metadata: {
    name: string
    namespace: string
    labels: {
      app: string
    }
  }
  status: {
    phase: string
    podIP: string
    startTime: string
  }
}

interface ListPodResp {
  pods: {
    items: Pod[]
  }
}

export default Deploy;
export {
  Deploy,
  ListReq,
  ListResp,
  CreateReq,
  CreateResp,
  DeployItem,
  DeleteReq,
  GetReq,
  GetResp,
  UpdateReq,
  UpdateResp,
  ListPodReq,
  ListPodResp,
  Pod
};
